import java.util.Scanner;

public class Test03{
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        int m = 1;
        int max_m = 0;
        while(m <= a && m <= b){
            if(a % m == 0 && b % m ==0){
                max_m=m;
            }
            m++;
        }
    System.out.println(max_m);
    }
}